package com.wyl.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wyl.mapper.DetailMapper;
import com.wyl.model.Detail;
@Service("detailService")
public class DetailService {

	@Autowired
	DetailMapper detailMapper;
	
	public Detail selectById(int id) {
		return detailMapper.selectById(id);
	}
	
	public void clearTable(){
		detailMapper.clear();
	}
	
	public void save(Detail detail) {
		if(detail.getOldTitle()!=null){
			//if(detail.getOldTitle().length()>6)
			detail.setOldTitle(detail.getOldTitle().substring(5,detail.getOldTitle().length()-1));
		}
		else{
			detail.setOldTitle(null);
		}
		
		
		detailMapper.save(detail.getSimpleId(), detail.getTitle(),
				detail.getTime(), detail.getFrom(), detail.getOldTitle(), detail.getContent());
	}
}
